import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: "/login",
    },
    {
        path: '/home',
        component: () => import('../views/Home'),
        redirect: '/home/index',
        children: [
            // 首页
            {

                path: 'index',
                component: () => import('../views/index/index.vue')
            },
            // 组织
            {
                name: "formal",
                path: 'formal',
                component: () => import('../organization/formal.vue')
            },
            {
                name: "organ",
                path: 'organ',
                component: () => import('../organization/organ.vue')
            },
            // 职务
            {
                name: "duty",
                path: 'duty',
                component: () => import('../organization/duty.vue')
            },
            // 档案
            {
                name: "record",
                path: 'record',
                component: () => import('../organization/record.vue')
            },
            // 人事
            {
                name: "staff",
                path: 'staff',
                component: () => import('../organization/staff.vue')
            },
            {
                path: 'station',
                component: () => import('../organization/station.vue')
            },
            {
                name: "timer",
                path: 'timer',
                component: () => import('../organization/timer.vue')
            },

            // 转正的表单
            {
                path: 'converted',
                component: () => import('../organization/converted.vue')
            },
            // 离职的表单
            {
                name: "outgoing",
                path: 'outgoing',
                component: () => import('../organization/outgoing.vue')
            },
            // 社保公积金模块
            // 社保方案
            {
                name: 'soseplan',
                path: 'soseplan',
                component: () => import('../views/Soseprofund/Soseplan/Index')
            },
            // 社保方案的添加
            {
                path: 'addplan',
                component: () => import('../views/Soseprofund/Soseplan/Index1')
            },
            // 社保方案的编辑
            {
                path: 'editplan',
                component: () => import('../views/Soseprofund/Soseplan/Index2')
            },
            // 公积金方案
            {
                name: "profundplan",
                path: 'profundplan',
                component: () => import('../views/Soseprofund/Profunplan/Index')
            },
            // 公积金方案的添加
            {
                name: "addprofund",
                path: 'addprofund',
                component: () => import('../views/Soseprofund/Profunplan/Index1')
            },
            // 公积金方案的编辑
            {
                path: 'editprofund',
                component: () => import('../views/Soseprofund/Profunplan/Index2')
            },
            // 增减人员
            {
                path: 'incdec',
                component: () => import('../views/Soseprofund/Incdecper/Index')
            },
            // 参保档案
            {
                path: 'insrecord',
                component: () => import('../views/Soseprofund/Insur_records/Index')
            },
            // 险种设置
            {
                path: 'instype',
                component: () => import('../views/Soseprofund/Insurtypesetting/Index')
            },
            //员工薪资
            // 薪资档案
            {
                name: 'paypaper',
                path: 'paypaper',
                component: () => import('../views/Memberpay/Paypaper/Index')
            },
            // 薪资调整
            {
                path: 'paytiaozheng',
                component: () => import('../views/Memberpay/Paytiaozheng/Index')
            },
            // 定薪模板
            {
                path: 'dingpay',
                component: () => import('../views/Memberpay/Dingpaymoban/Index')
            },
            // 薪资核算
            // 薪资项目
            {
                name: "payxiangmu",
                path: 'payxiangmu',
                component: () => import('../views/meony/Payxiangmu/Index')
            },
            // 薪资方案
            {
                name: "payfangan",
                path: 'payfangan',
                component: () => import('../views/meony/Payfangan/Index')
            },
            // 薪资台账
            {
                name: "paytaizhang",
                path: 'paytaizhang',
                component: () => import('../views/meony/Paytaizhang/Index')
            },
            // 详情
            {
                name: "select1",
                path: 'select1',
                component: () => import('../views/meony/Paytaizhang/select')
            },
            //考勤模块
            {
                path: 'holiday',
                component: () => import('../views/Attendance/holiday/HolidayPay')
            },
            //考勤模块编辑
            {
                path: 'edit',
                component: () => import('../views/Attendance/holiday/edit')
            },
            //考勤模块新增
            {
                path: 'add',
                component: () => import('../views/Attendance/holiday/add')
            },
            //计算页面
            {
                path: 'sums',
                component: () => import('../views/Attendance/holiday/sum')
            },
            //旷工模块
            {
                path: 'people',
                component: () => import('../views/Attendance/Absenteeism/people')
            },
            //旷工模块添加
            {
                path: 'adds',
                component: () => import('../views/Attendance/Absenteeism/add')
            },
            //旷工模块编辑
            {
                path: 'edits',
                component: () => import('../views/Attendance/Absenteeism/edit')
            },
            //加班计薪规则模块
            {
                path: 'works',
                component: () => import('../views/Attendance/works/works')
            },
            //加班模块的添加
            {
                path: 'worksadd',
                component: () => import('../views/Attendance/works/add')
            },
            //加班模块的编辑
            {
                path: 'worksedit',
                component: () => import('../views/Attendance/works/edit')
            },
            //缺卡考勤规则模块
            {
                path: 'cards',
                component: () => import('../views/Attendance/cards/cards')
            },
            //缺卡扣款的添加
            {
                path: 'cardsadd',
                component: () => import('../views/Attendance/cards/add')
            },
            //缺卡扣款的编辑
            {
                path: 'cardsedit',
                component: () => import('../views/Attendance/cards/edit')
            },
            //迟到早退扣款规则
            {
                path: 'late',
                component: () => import('../views/Attendance/late/late')
            },
            //迟到早退扣款的添加
            {
                path: 'lateadd',
                component: () => import('../views/Attendance/late/add')
            },
            //迟到早退扣款的编辑
            {
                path: 'lateedit',
                component: () => import('../views/Attendance/late/edit')
            },
            //全勤奖规则
            {
                path: 'encourage',
                component: () => import('../views/Attendance/encourage/encourage')
            },
            //全勤奖的添加
            {
                path: 'encourageadd',
                component: () => import('../views/Attendance/encourage/add')
            },
            //全勤奖的编辑
            {
                path: 'encourageedit',
                component: () => import('../views/Attendance/encourage/edit')
            },
            //考勤报表
            {
                path: 'baobiao',
                component: () => import('../views/Attendance/baobiao/index')
            },
            {
                path: 'select',
                component: () => import('../views/Attendance/baobiao/select')
            },
            // 个税路由开始  ↓
            {
                // 专项附加扣除
                path: 'deduct',
                component: () => import('../views/individualTaxes/deduct.vue')
            },
            {
                // 专项附加扣除---个人详细
                path: 'deductInfo',
                component: () => import('../views/individualTaxes/deductInfo.vue')
            },
            {
                // 纳税额
                path: 'ratal',
                component: () => import('../views/individualTaxes/ratal.vue')
            },
            {
                path: 'ratalInfo',
                component: () => import('../views/individualTaxes/ratalInfo.vue')
            },
            {
                //     计税规则
                path: 'rules',
                component: () => import('../views/individualTaxes/rules.vue')
            },
            {
                //     计税规则
                path: 'ruleAdd',
                component: () => import('../views/individualTaxes/ruleAdd.vue')
            },
            {
                path: 'staffAdd',
                component: () => import('../views/individualTaxes/staffAdd.vue')
            },
            // 个税路由结束  ↑

            //工资单管理
            {
                //工资单设置
                path: 'pay',
                component: () => import('../views/Wages/pay.vue')
            },
            {
                //工资发放
                path: 'grant',
                name: "grant",
                component: () => import('../views/Wages/grant.vue')
            },
            {
                //新建发放工资单
                path: 'addgrant',
                component: () => import('../views/Wages/addgrant.vue')
            }, {
                //新增工资单设置
                path: 'addpay',
                component: () => import('../views/Wages/addpay.vue')
            }, {
                //编辑工资单设置
                path: 'editpay',
                component: () => import('../views/Wages/editpay.vue')
            }, {
                //工资单详情
                path: 'detail',
                component: () => import('../views/Wages/detail.vue')
            },
            // 系统设置
            // 用户管理
            {
                path: 'user',
                component: () => import('../views/System/userAdmin/user.vue')
            },
            // 角色管理
            {
                path: 'role',
                component: () => import('../views/System/roleAdmin/role.vue')
            },
            // 分配权限
            {
                path: 'setting',
                component: () => import('../views/System/setting/setting.vue')
            },
            // 个人设置
            {
                path: 'person',
                component: () => import('../views/System/personAdmin/person.vue')
            },
            // 个性化设置
            {
                path: 'individuation',
                component: () => import('../views/System/individuationAdmin/individuation')
            },

        ],
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login')
    },

]

const router = new VueRouter({
    mode: 'history',
    routes,

})


router.beforeEach((to, from, next) => {
    //如果路由需要跳转
    if (to.path != "/login") {
        //判断 如果本地缓存是token的时候，可以进去
        if (sessionStorage.getItem('token')) {
            next()  //放行
        } else {
            next(from.path)
        }
    } else {
        // 否则，放行
        next()
    }

})

export default router
